<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>配置管理</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
            background-color: #f5f5f5;
        }

        .container {
            max-width: 1200px;
            margin: 0 auto;
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        h1 {
            color: #333;
            text-align: center;
        }

        .gitee-config {
            background-color: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 4px;
            padding: 20px;
            margin: 20px 0;
        }

        .gitee-config h3 {
            margin-top: 0;
            color: #495057;
        }

        .form-group {
            margin-bottom: 15px;
        }

        .form-group label {
            display: inline-block;
            width: 120px;
            font-weight: bold;
            color: #495057;
        }

        .form-group input {
            width: 300px;
            padding: 8px;
            border: 1px solid #ced4da;
            border-radius: 4px;
        }

        .sync-status {
            background-color: #e9ecef;
            border: 1px solid #ced4da;
            border-radius: 4px;
            padding: 15px;
            margin: 20px 0;
        }

        .sync-status h3 {
            margin-top: 0;
            color: #495057;
        }

        .sync-status p {
            margin: 5px 0;
            color: #6c757d;
        }

        .controls {
            margin: 20px 0;
            text-align: center;
        }

        button {
            margin: 5px;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            background-color: #007bff;
            color: white;
            cursor: pointer;
            font-size: 14px;
        }

        button:hover {
            background-color: #0056b3;
        }

        button:disabled {
            background-color: #6c757d;
            cursor: not-allowed;
        }

        .config-list {
            margin-top: 20px;
        }

        .config-item {
            background-color: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 4px;
            padding: 15px;
            margin-bottom: 10px;
        }

        .config-item h3 {
            margin-top: 0;
            color: #495057;
        }

        .config-item textarea {
            width: 100%;
            min-height: 100px;
            margin: 10px 0;
            padding: 8px;
            border: 1px solid #ced4da;
            border-radius: 4px;
            font-family: monospace;
        }

        .config-item button {
            margin: 5px;
            padding: 5px 10px;
            font-size: 12px;
        }

        .add-item-form {
            background-color: #e9ecef;
            padding: 20px;
            border-radius: 4px;
            margin-bottom: 20px;
        }

        .add-item-form input, .add-item-form textarea {
            width: 100%;
            margin: 5px 0;
            padding: 8px;
            border: 1px solid #ced4da;
            border-radius: 4px;
        }

        .status {
            text-align: center;
            padding: 10px;
            margin: 10px 0;
            border-radius: 4px;
            display: none;
        }

        .status.success {
            background-color: #d4edda;
            color: #155724;
            border: 1px solid #c3e6cb;
        }

        .status.error {
            background-color: #f8d7da;
            color: #721c24;
            border: 1px solid #f5c6cb;
        }

        .sync-success {
            color: #28a745;
            font-weight: bold;
        }

        .sync-error {
            color: #dc3545;
            font-weight: bold;
        }

        .sync-warning {
            color: #ffc107;
            font-weight: bold;
        }

        /* 同步历史样式 */
        .sync-history {
            background: #f9f9f9;
            border-radius: 8px;
            padding: 15px;
            margin-top: 20px;
        }

        .sync-history h3 {
            margin-top: 0;
            color: #333;
            font-size: 16px;
        }

        .history-container {
            max-height: 300px;
            overflow-y: auto;
        }

        .history-item {
            display: flex;
            align-items: center;
            padding: 8px 0;
            border-bottom: 1px solid #eee;
            font-size: 12px;
        }

        .history-item:last-child {
            border-bottom: none;
        }

        .history-type {
            font-weight: bold;
            min-width: 100px;
            color: #666;
        }

        .history-time {
            color: #999;
            margin: 0 10px;
            flex: 1;
        }

        .history-status {
            min-width: 40px;
            text-align: center;
            font-weight: bold;
        }

        .history-item.success .history-status {
            color: #28a745;
        }

        .history-item.error .history-status {
            color: #dc3545;
        }

        .history-message {
            color: #666;
            margin-left: 10px;
            flex: 2;
        }
        
        /* 变量按钮样式 */
        .variable-buttons {
            margin: 15px 0;
            padding: 10px;
            background-color: #f8f9fa;
            border-radius: 4px;
            border: 1px solid #e9ecef;
        }
        
        .variable-buttons h4 {
            margin: 0 0 10px 0;
            color: #495057;
            font-size: 14px;
        }
        
        .variable-buttons-container {
            display: flex;
            flex-wrap: wrap;
            gap: 8px;
        }
        
        .variable-btn {
            padding: 6px 12px;
            background-color: #e9ecef;
            color: #495057;
            border: 1px solid #ced4da;
            border-radius: 3px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.2s;
        }
        
        .variable-btn:hover {
            background-color: #dee2e6;
            border-color: #adb5bd;
        }
        
        .variable-btn:active {
            background-color: #ced4da;
        }
    </style>
</head>
<body>
<div class="container">
    <h1>酒店配置管理工具</h1>

    <!-- Gitee配置设置 -->
     <div class="gitee-config">
        <h3>Gitee 仓库配置</h3>
        <div class="form-group">
            <label>仓库所有者:</label>
            <input type="text" id="giteeOwner" placeholder="例如: your-username" readonly>
        </div>
        <div class="form-group">
            <label>仓库名称:</label>
            <input type="text" id="giteeRepo" placeholder="例如: hotel-config" readonly>
        </div>
        <div class="form-group">
            <label>文件路径:</label>
            <input type="text" id="giteePath" placeholder="例如: hotel-config.json" readonly>
        </div>
        <div class="form-group">
            <label>分支:</label>
            <input type="text" id="giteeBranch" placeholder="例如: master" readonly>
        </div>
        <div class="form-group">
            <label>Token:</label>
            <input type="password" id="giteeToken" placeholder="您的Gitee访问令牌" readonly>
        </div>
        <button id="testGiteeConnection">测试连接</button>
    </div> 

    <!-- 同步状态显示 -->
<!--    <div class="sync-status">-->
<!--        <h3>同步状态</h3>-->
<!--        <div id="syncStatusDisplay">-->
<!--            <p>自动同步: <span id="autoSyncStatus">加载中...</span></p>-->
<!--            <p>最后同步时间: <span id="lastSyncTime">从未同步</span></p>-->
<!--            <p>最后获取时间: <span id="lastFetchTime">从未获取</span></p>-->
<!--            <p id="syncError" style="color: red; display: none;"></p>-->
<!--        </div>-->
    </div>

    <!-- 同步历史 -->
<!--    <div class="sync-history">-->
<!--        <h3>同步历史</h3>-->
<!--        <div id="syncHistory" class="history-container">-->
<!--            &lt;!&ndash; 同步历史记录将在这里显示 &ndash;&gt;-->
<!--        </div>-->
<!--    </div>-->

    <div class="add-item-form">
        <input type="text" id="newHotelName" placeholder="酒店名称">
        <input type="text" id="newTemplate" placeholder="模板内容">
        
        <!-- 变量按钮区域 -->
        <div class="variable-buttons">
            <h4>可用变量：</h4>
            <div class="variable-buttons-container">
                <button class="variable-btn" data-variable="${hotelName}">酒店名称</button>
                <button class="variable-btn" data-variable="${userName}">入住人姓名</button>
                <button class="variable-btn" data-variable="${roomType}">房型</button>
                <button class="variable-btn" data-variable="${mealType}">餐型</button>
                <button class="variable-btn" data-variable="${startDate}">入住日期</button>
                <button class="variable-btn" data-variable="${endDate}">离店日期</button>
                <button class="variable-btn" data-variable="${roomNum}">房间数</button>
                <button class="variable-btn" data-variable="${nightNum}">晚数</button>
                <button class="variable-btn" data-variable="${channel}">渠道</button>
                <button class="variable-btn" data-variable="</br>">换行</button>
            </div>
        </div>
        
        <button class="add-button" id="addNewItem">添加新配置</button>
    </div>

    <div class="config-section" id="configSection" style="height: 500px;overflow: auto">
        <!-- 配置项将在这里动态生成 -->
    </div>

    <div class="button-group">
<!--        <button id="saveConfig">保存配置</button>-->
<!--        <button id="resetConfig">重置为默认配置</button>-->
<!--        <button id="exportConfig">导出配置</button>-->
<!--        <button id="importConfig">导入配置</button>-->
<!--        <button id="syncToGitee">同步到Gitee</button>-->
       <button id="fetchFromGitee">从Gitee获取</button>
<!--        <button id="toggleAutoSync">关闭自动同步</button>-->
    </div>

    <div id="status" class="status" style="display: none;"></div>
</div>

<input type="file" id="fileInput" style="display: none;" accept=".json">

<script src="config-manager.js?t=202312011213"></script>

</body>
</html>
